#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5;
int d[MAXN+5],v[MAXN+5],a[MAXN+5],p[MAXN+5];
int l[MAXN+5],r[MAXN+5],num[MAXN+5];
bool f[MAXN+5];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T,n,m,L,V;
    scanf("%d",&T);
    for(int z=1;z<=T;z++){
        scanf("%d%d%d%d",&n,&m,&L,&V);
        for(int i=1;i<=n;i++){
            f[i]=false;
            num[i]=0;
            scanf("%d%d%d",&d[i],&v[i],&a[i]);
        }
        for(int i=1;i<=m;i++) scanf("%d",&p[i]);
        int cnt=0;
        for(int i=1;i<=n;i++){
            if(v[i]<=V&&a[i]<=0) continue;
            if(v[i]>V&&a[i]>=0){
                if(p[m]>=d[i]){
                    cnt++;
                    f[i]=true;
                    l[i]=d[i],r[i]=L;
                    for(int j=1;j<=m;j++){
                        if(p[j]>=l[i]&&p[j]<=r[i]){
                            num[i]++;
                        }
                    }
                }
            }else if(v[i]<=V&&a[i]>0){
                double y=(1.0*V*V-1.0*v[i]*v[i])/(2*a[i]);
                int x=d[i]+(int)ceil(y);
                if(ceil(y)==floor(y)) x++;
                if(p[m]>=x){
                    cnt++;
                    f[i]=true;
                    l[i]=x,r[i]=L;
                    for(int j=1;j<=m;j++){
                        if(p[j]>=l[i]&&p[j]<=r[i]){
                            num[i]++;
                        }
                    }
                }
            }else if(v[i]>V&&a[i]<0){
                double y=(1.0*V*V-1.0*v[i]*v[i])/(2*a[i]);
                int x=d[i]+(int)floor(y);
                if(floor(y)==ceil(y)) x--;
                bool flag=false;
                for(int j=1;j<=m;j++){
                    if(p[j]>=d[i]&&p[j]<=x){
                        flag=true;
                        break;
                    }
                }
                if(flag){
                    cnt++;
                    f[i]=true;
                    l[i]=d[i],r[i]=x;
                    for(int j=1;j<=m;j++){
                        if(p[j]>=l[i]&&p[j]<=r[i]){
                            num[i]++;
                        }
                    }
                }
            }
        }
        printf("%d ",cnt);
        int ans=0;
        for(int i=1;i<=m;i++){
            bool flag=false;
            for(int j=1;j<=n;j++){
                if(!f[j]) continue;
                if(p[i]>=l[j]&&p[i]<=r[j]&&num[j]<=1){
                    flag=true;
                    break;
                }
            }
            if(!flag){
                ans++;
                for(int j=1;j<=n;j++){
                    if(!f[j]) continue;
                    if(p[i]>=l[j]&&p[i]<=r[j]) num[j]--;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}
